    //
//  ChannelEditViewController.m
//  RssReader
//
//  Created by Wang Shuguang on 12-5-25.
//  Copyright 2012 Dawn. All rights reserved.
//

#import "ChannelEditViewController.h"
#import "Rss.h"


@implementation ChannelEditViewController
@synthesize channelIndex;
@synthesize dataArray;

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
	
	self.view.backgroundColor = [UIColor colorWithRed:224.0f/255.0f green:224.0f/255.0f blue:224.0f/255.0f alpha:1.0f];
	
	//导航条
	UIImageView *navView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 37)];
	navView.image = [UIImage noCacheImageNamed:@"navbar_background.png"];
	navView.userInteractionEnabled = YES;
	[self.view addSubview:navView];
	//返回按钮
	UIButton *backButton = [PublicMethods buttonWithImage:nil 
										  backgroundImage:[UIImage noCacheImageNamed:@"navbar_back_normal.png"] 
							   highlightedBackgroundImage:[UIImage noCacheImageNamed:@"navbar_back_heighlight.png"]];
	backButton.frame = CGRectMake(0, 0, 47, 35);
	[backButton addTarget:self action:@selector(navBack:) forControlEvents:UIControlEventTouchUpInside];
	[navView addSubview:backButton];
	//编辑按钮
	addButton = [PublicMethods buttonWithImage:nil 
								backgroundImage:[UIImage noCacheImageNamed:@"white_btn_press.png"] 
					 highlightedBackgroundImage:[UIImage noCacheImageNamed:@"white_btn_normal.png"]];
	addButton.frame = CGRectMake(270, 3, 46, 30);
	addButton.titleLabel.font = [UIFont systemFontOfSize:14.0f];
	[addButton setTitle:@"完成" forState:UIControlStateNormal];
	[addButton setTitleColor:[UIColor colorWithRed:30.0f/255.0f green:140.0f/255.0f blue:199.0f/255.0f alpha:1] forState:UIControlStateHighlighted];
	[addButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
	[addButton addTarget:self action:@selector(beginEditing:) forControlEvents:UIControlEventTouchUpInside];
	[navView addSubview:addButton];
	
	Rss *rss = [Rss shareRss];
	NSDictionary *channel = [rss.channels objectAtIndex:channelIndex];
	self.dataArray = [NSArray arrayWithContentsOfFile:[NSString stringWithFormat:@"%@.plist",[rss channelPathForKey:[channel objectForKey:@"Url"]]]];
	
	UITableView *channelInfoTV = [[UITableView alloc] initWithFrame:CGRectMake(0, 37, 320, 460-37)];
	[self.view addSubview:channelInfoTV];
	channelInfoTV.delegate = self;
	channelInfoTV.dataSource = self;
	[channelInfoTV release];
}


#pragma mark -
#pragma mark UITableViewDataSource
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView{
	return 2;
}

-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
	if (section == 0) {
		return 3;
	}else {
		return [dataArray count];
	}
}

-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
	
}

- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView{
	return [NSArray arrayWithObjects:@"频道信息",@"已更新数据",nil];
}

					  
-(void)beginEditing:(id)sender{
	
}
-(void) navBack:(id)sender{
	[self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc. that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
	[dataArray release];
}


@end
